show category list
<script src="http://img.kekenet.com/statics/js/jquery.min.js"></script>
<style>
* { margin: 0; padding: 0; }
</style>
<div style="float: left; width: 200px;">
<ul>
{{foreach from=$cats item=c}}
    <li><a href="../index.php/category.index?pid={{$c['catid']}}">{{$c['catname']}}</a>&nbsp;<a href="../index.php/detail.add?pid={{$c['catid']}}">添加</a></li>
{{/foreach}}
</ul>
</div>
<div style="float: left; width: 800px;">
	<ul>
	{{foreach from=$sub_cats item=c}}
	    <li style="float: left; padding-right: 30px;"><a href="../index.php/category.index?pid={{$pid}}&cid={{$c['catid']}}">{{$c['catname']}}</a></li>
	{{/foreach}}
	</ul>
	
	<div style="clear: both;"></div>
	<hr />
	<br />
	
	<ul>
	{{foreach from=$cil_cats item=c}}
	    <li style="float: left; padding-right: 30px;"><a href="../index.php/category.index?pid={{$pid}}&cid={{$cid}}&catid={{$c['catid']}}">{{$c['catname']}}</a></li>
	{{/foreach}}
	</ul>
	
	<div style="clear: both;"></div>
	<hr />
	<br />
	<ul>
	{{foreach from=$artlist item=c}}
	    <li>
	    	<input type="checkbox" name="sel[]" value="{{$c['id']}}" />
	    	{{$c['id']}}&nbsp;
	    	<a href="../index.php/category.index?pid={{$pid}}&cid={{$c['cat_info']['parentid']}}&catid={{$c['cat_info']['catid']}}">{{$c['cat_info']['catname']}}</a>&nbsp;&nbsp;
	    	<a href="../index.php/detail.edit?id={{$c['id']}}">{{$c['title']}}</a> {{$c['username']}} {{$c['inputtime']}}
	    	<a target="preview" href="../index.php/detail.index?id={{$c['id']}}&do=preview">预览</a>
	    	<a href="../index.php/detail.edit?pid={{$pid}}&id={{$c['id']}}">编辑</a>
	    </li>
	{{/foreach}}
	</ul>
	
	<div>
	{{foreach from=$pages item=c}}
	    <a href="../index.php/category.index?pid={{$pid}}&cid={{$cid}}&catid={{$catid}}&page={{$c}}">{{$c}}</a>
	{{/foreach}}
	</div>
	
	<hr />
	<br />
	<div style="float:left;">
		<a target="preview" href="../index.php/category.index?pid={{$pid}}&cid={{$cid}}&catid={{$catid}}&do=preview">预览当前栏目</a>
	</div>
	<div style="float:right;">
		<input id="make_current_btn" type="button" value="生成当前栏目" />
		<input id="make_select_btn" type="button" value="生成选中的内容" />
		<input id="make_all_btn" type="button" value="生成当前栏目内容" />
	</div>
	<div style="clear:both;"></div>
</div>

<div id="output_info" style="height: 100px; clear:both; overflow:scroll;">
	<div id="title"></div>
	<div id="list"></div>
</div>

<script>
function clear_output() {
	$('#output_info #title').html('');
	$('#output_info #list').html('');
}
function call(url, callback) {
	$.getJSON(url, callback);
}
function make_static_content(ids) {
	var ids_length = ids.length;
	$('#output_info #title').html('生成<span id="maked_cnt">0</span> / ' + ids_length + '个页面');
	
	function make() {
		var xids = ids.slice(0, 5);
		$(xids).each(function(k, v){
			call('../index.php/detail.index?do=makestatic&id=' + v, function(data){
				if(data.status==1) {
					var cnt = parseInt($('#maked_cnt').html());
					$('#maked_cnt').html(++cnt);
					$('#output_info #list').prepend('<p>' + data.id + ' 生成成功.</p>');
				}
			});
		});
		ids = ids.slice(5);
		if(ids.length > 0) {
			setTimeout(function(){ make() }, 300);
		}
	}
	make();
}
$(document).ready(function(){
	$('#make_current_btn').click(function(){
		clear_output();
		$('#output_info #title').html('生成{{$caid}}');
		call('../index.php/category.index?pid={{$pid}}&cid={{$cid}}&catid={{$catid}}&do=makestatic', function(data){
			if(data.status==1) {
				$('#output_info #list').prepend('<p>' + data.catid + ' 生成成功.</p>');
				if(typeof(data.max_page) != 'undefined') {
					$('#output_info #list').prepend('<p>' + data.catid + ' 生成相关分页, 共' + data.max_page + '页.</p>');
					for(var page = 2; page <= data.max_page; page++) {
						call('../index.php/category.index?pid={{$pid}}&cid={{$cid}}&catid={{$catid}}&do=makestatic&page=' + page, function(data){
							$('#output_info #list').prepend('<p>第 ' + data.page + ' 页 生成成功.</p>');
						});
					}
				}
			}
		});
	});
	$('#make_all_btn').click(function(){
		clear_output();
		call('../index.php/category.get_index?catid={{$caid}}', function(data){
			make_static_content(data.ids);
		});
	});
	$('#make_select_btn').click(function(){
		clear_output();
		var ids = [];
		$('input[name=sel[]][checked]').each(function(){
			ids.push($(this).val());
		});
		make_static_content(ids);
	});	
});
</script>

<iframe id="preview" name="preview" src="about:blank" width="100%" height="400px"></iframe>